/*     */ package com.zimbra.qa.unittest;
/*     */ 
/*     */ import com.zimbra.client.ZFolder;
/*     */ import com.zimbra.client.ZMailbox;
/*     */ import com.zimbra.client.ZMountpoint;
/*     */ import com.zimbra.common.util.StringUtil;
/*     */ import java.util.Arrays;
/*     */ import java.util.HashSet;
/*     */ import java.util.List;
/*     */ import java.util.Set;
/*     */ import junit.framework.TestCase;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class TestMountpoint
/*     */   extends TestCase
/*     */ {
/*  36 */   private static final String NAME_PREFIX = TestMountpoint.class.getName();
/*     */   private static final String USER_NAME = "user1";
/*     */   private static final String REMOTE_USER_NAME = "user2";
/*     */   
/*     */   public void setUp() throws Exception
/*     */   {
/*  42 */     cleanUp();
/*     */   }
/*     */   
/*     */   public void tearDown() throws Exception
/*     */   {
/*  47 */     cleanUp();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public void testDummy() {}
/*     */   
/*     */ 
/*     */   public void testInvalidMountpoint()
/*     */     throws Exception
/*     */   {
/*  58 */     ZMailbox mbox = TestUtil.getZMailbox("user1");
/*  59 */     ZMailbox remoteMbox = TestUtil.getZMailbox("user2");
/*  60 */     String remoteFolderPath = "/" + NAME_PREFIX + "-testInvalidMountpoint-remote";
/*  61 */     ZFolder remoteFolder = TestUtil.createFolder(remoteMbox, remoteFolderPath);
/*  62 */     ZMountpoint mountpoint = TestUtil.createMountpoint(remoteMbox, remoteFolderPath, mbox, NAME_PREFIX + "-mountpoint");
/*     */     
/*     */ 
/*  65 */     Set<String> folderIds = new HashSet();
/*  66 */     folderIds.add(mountpoint.getId());
/*  67 */     String inboxId = Integer.toString(2);
/*  68 */     folderIds.add(inboxId);
/*  69 */     String idString = mbox.getValidFolderIds(StringUtil.join(",", folderIds));
/*  70 */     List<String> returnedIds = Arrays.asList(idString.split(","));
/*  71 */     assertEquals(2, returnedIds.size());
/*  72 */     assertTrue(returnedIds.contains(inboxId));
/*  73 */     assertTrue(returnedIds.contains(mountpoint.getId()));
/*  74 */     assertEquals(1, getNumCommas(idString));
/*     */     
/*     */ 
/*  77 */     remoteMbox.deleteFolder(remoteFolder.getId());
/*  78 */     idString = mbox.getValidFolderIds(StringUtil.join(",", folderIds));
/*  79 */     returnedIds = Arrays.asList(idString.split(","));
/*  80 */     assertEquals(1, returnedIds.size());
/*  81 */     assertTrue(returnedIds.contains(inboxId));
/*  82 */     assertEquals(0, getNumCommas(idString));
/*     */   }
/*     */   
/*     */   private int getNumCommas(String s) {
/*  86 */     int numCommas = 0;
/*  87 */     for (int i = 0; i < s.length(); i++) {
/*  88 */       if (s.charAt(i) == ',') {
/*  89 */         numCommas++;
/*     */       }
/*     */     }
/*  92 */     return numCommas;
/*     */   }
/*     */   
/*     */   private void cleanUp() throws Exception
/*     */   {
/*  97 */     TestUtil.deleteTestData("user1", NAME_PREFIX);
/*  98 */     TestUtil.deleteTestData("user2", NAME_PREFIX);
/*     */   }
/*     */   
/*     */   public static void main(String[] args) throws Exception
/*     */   {
/* 103 */     TestUtil.cliSetup();
/* 104 */     TestUtil.runTest(TestMountpoint.class);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/TestMountpoint.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */